var assert = require('assert');
var logger = using('easynode.framework.Logger').forFile(__filename);
var GenericObject = using('easynode.GenericObject');
var BeanFactory = using('easynode.framework.BeanFactory');
var thunkify = require('thunkify');
var fs=require('fs');
var request = require("co-request");
(function () {
        const baseURL=EasyNode.config('remoteServer.address','http://api.uwaytech.cn:3389');
        /**
         * Class RequestWarpper
         *
         * @class #NAMESPACE#.RequestWarpper
         * @extends easynode.GenericObject
         * @since 0.1.0
         * @author zlbbq
         * */
        class RequestWarpper extends GenericObject {
                /**
                 * 构造函数。
                 *
                 * @method 构造函数
                 * @since 0.1.0
                 * @author zlbbq
                 * */
                constructor() {
                        super();
                        //调用super()后再定义子类成员。
                        this.cache = null;
                }

                /**
                 * 初始化连接参数。
                 *
                 * @method get
                 * @param {String} key 键
                 * @param {Object} defaultValue 默认值，默认null
                 * @return {Object} 返回缓存的值
                 * @async
                 * @since 0.1.0
                 * @author zlbbq
                 * */
                initialize() {
                        var me=this;
                        var baseRequest = request.defaults({
                                baseUrl: baseURL,
                                method: "POST"
                        })
                        this.baseRequest=baseRequest;
                }

                getBaseRequest()
                {
                        return this.baseRequest;
                }


                //   var j=me.requestWarpper.getJar();
                // var cookie_string = j.getCookieString('http://api.uwaytech.cn:3389/v1/login'); // "key1=value1; key2=value2; ..."
                //logger.error(cookie_string);
                // var cookies = j.getCookies('http://api.uwaytech.cn:3389/v1/login');
                // logger.error('response: '+JSON.stringify(response));

                getClassName() {
                        return EasyNode.namespace(__filename);
                }
        }

        module.exports = RequestWarpper;
})();